package com.blue.jdbc;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.List;
import java.util.Map;

/**
 * 对象工具类
 * 
 * @author zhengj
 * @since 1.0 2011-4-4
 */
public class ObjectUtil
{
	private ObjectUtil()
	{
	}
	
	public static List<Map<String, Object>> convert(List<Map<String, Object>> list)
	{
		if (list == null)
			return null;
		
		for (Map<String, Object> map : list)
		{
			for (Map.Entry<String, Object> entry : map.entrySet())
			{
				if (entry.getValue() == null)
					continue;
				
				Class<?> clazz = entry.getValue().getClass();
				if (clazz == BigDecimal.class)
				{
					BigDecimal d = (BigDecimal)entry.getValue();
					entry.setValue(d.doubleValue());
				}
				else if (clazz == BigInteger.class)
				{
					BigInteger i = (BigInteger)entry.getValue();
					entry.setValue(i.intValue());
				}
			}
		}
		
		return list;
	}
}
